#include <REGX52.H>

void delay_ms(unsigned int ms)
{
    unsigned int i, j;
    for (i = 0; i < ms; i++)
    {
        for (j = 0; j < 123; j++)
            ;
    }
}
sbit BTN1=P3^4;
sbit BTN2=P3^7;
#define count_max 5
void main()
{
    unsigned int count = 0;
    P2=0xFF;
    while(1)
    {
        if (BTN1==0)
        {
            if(count>=count_max)
            {
                P2-=1;
                count=0;
                delay_ms(500);
            }
            else
            {
                count++;
            }
        }
        if (BTN2==0)
        {
           if(count>=count_max)
            {
                P2+=1;
                count=0;
                delay_ms(500);
            }
            else
            {
                count++;
            }
        }
    }
}
